<!DOCTYPE html>
<html lang="zh">
<head>
    <title>配置组管理 - virus CMS</title>
    {include file="common/meta" /}
</head>
<body>

<!-- Navbar -->
{include file="common/header" /}
<!-- /Navbar -->
<!-- Main Container -->
<div class="main-container container-fluid">
    <!-- Page Container -->
    <div class="page-container">

        <!-- Page Sidebar -->
        {include file="common/sidebar" /}
        <!-- /Page Sidebar -->
        <!-- Page Content -->
        <div class="page-content">
            <!-- Page Breadcrumb -->
            <div class="page-breadcrumbs">
                <ul class="breadcrumb">
                    <li class="active">
                        <i class="fa fa-home"></i>&nbsp;控制面板
                    </li>
                    <li>
                        <i class="fa fa-cogs"></i> 常规管理
                    </li>
                    <li>
                        <i class=""></i> 配置组管理
                    </li>
                </ul>
            </div>
            <!-- /Page Breadcrumb -->
            <!-- Page Body -->
            <div class="page-body">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="widget radius-bordered">
                            <div class="widget-header bordered-bottom bordered-themeprimary">
                                <span class="widget-caption">添加配置组</span>
                            </div>
                            <div class="widget-body">
                                <form class="form-horizontal">
                                    <div class="form-group">
                                        <label for="group_name"
                                               class="col-sm-2 control-label no-padding-right">配置组变量</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" id="group_name" name="group_name"
                                                   placeholder="配置组变量"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <label for="group_title"
                                               class="col-sm-2 control-label no-padding-right">配置组标题</label>
                                        <div class="col-sm-6">
                                            <input type="text" class="form-control" id="group_title" name="group_title"
                                                   placeholder="配置组标题"/>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="col-sm-offset-2 col-sm-10">
                                            <button type="button" id="addConfigGroup" class="btn btn-primary">添加
                                            </button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <!-- /Page Body -->
        </div>
        <!-- /Page Content -->

    </div>
    <!-- /Page Container -->
    <!-- Main Container -->

</div>

{include file="common/script" /}
<script type="text/javascript">
    $(function () {
        $('#addConfigGroup').click(function () {
            // 前端参数判断
            let group_name = $('#group_name').val();
            let group_title = $('#group_title').val();
            if (group_name == "" || group_title == "") {
                toastr.error("配置组变量或配置组标题不能为空");
                return false;
            }

            url = '/admin/ConfigGroup/save';
            $.ajax({
                data: $('form').serialize(),
                type: "POST",
                url: url,
                dataType: 'json',
                success: (data) => {
                    if (data.code === 1) {
                        toastr.success(data.msg);
                        setTimeout(function () {
                            location.href = '/admin/ConfigGroup/index';
                        }, 2000);
                    } else {
                        toastr.error(data.msg);
                    }
                }
            });
            return false;
        });
    });
</script>
</body>
<!--  /Body -->
</html>
